package com.baseweb.webadmin.core.model.mapper;

import com.baseweb.webadmin.core.model.Sql.SqlProvider;
import com.baseweb.webadmin.core.model.bvo.ByUserExampleBvo;
import com.baseweb.webadmin.core.model.bvo.ByUserOrderInfoBvo;
import com.baseweb.webadmin.core.model.pojo.ByUserExample;
import com.baseweb.webadmin.core.model.pojo.ByUserExampleExample;
import java.util.List;

import com.baseweb.webadmin.core.util.RequestPage;
import org.apache.ibatis.annotations.*;

public interface ByUserExampleMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    int countByExample(ByUserExampleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    int deleteByExample(ByUserExampleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    @Delete({
        "delete from by_user_example",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    @Insert({
        "insert into by_user_example (user_id, img_url, ",
        "name, descn, status, ",
        "create_time, ",
        "update_time, ",
        "view_count, order_id, ",
        "order_detail_id, product_id, ",
        "example_type, case_time, ",
        "case_hotel, case_comment, ",
        "case_type, case_environment, ",
        "case_detail)",
        "values (#{userId,jdbcType=INTEGER}, #{imgUrl,jdbcType=VARCHAR}, ",
        "#{name,jdbcType=VARCHAR}, #{descn,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler}, ",
        "#{updateTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler}, ",
        "#{viewCount,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER}, ",
        "#{orderDetailId,jdbcType=INTEGER}, #{productId,jdbcType=INTEGER}, ",
        "#{exampleType,jdbcType=INTEGER}, #{caseTime,jdbcType=VARCHAR}, ",
        "#{caseHotel,jdbcType=VARCHAR}, #{caseComment,jdbcType=VARCHAR}, ",
        "#{caseType,jdbcType=VARCHAR}, #{caseEnvironment,jdbcType=VARCHAR}, ",
        "#{caseDetail,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(ByUserExample record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    int insertSelective(ByUserExample record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    List<ByUserExample> selectByExample(ByUserExampleExample example);

    /**
     * 分页查询我的作品
     * @param exampleBvo
     * @param requestPage
     * @return
     */
    @SelectProvider(type = SqlProvider.class,method = "selectUserExamplePageSql")
    @ResultMap("UserExampleUnionMap")
    List<ByUserExampleBvo> selectExampleBvoListByPage(@Param("exampleBvo")ByUserExampleBvo exampleBvo, @Param("page")RequestPage requestPage);

    /**
     * 我的作品总数
     * @param exampleBvo
     * @param requestPage
     * @return
     */
    @SelectProvider(type = SqlProvider.class,method = "countUserExamplePageSql")
    Integer countExampleBvoListByPage(@Param("exampleBvo")ByUserExampleBvo exampleBvo, @Param("page")RequestPage requestPage);
    @Select({
            "select",
            "id, user_id, img_url, name, descn, status, create_time, update_time, view_count, ",
            "order_id, order_detail_id, product_id, example_type, case_time, case_hotel, ",
            "case_comment, case_detail, case_type, case_environment ",
            "from by_user_example",
            "where status = 2 "
    })
    @ResultMap("BaseResultMap")
    List<ByUserExampleBvo> selectExampleBvoListCainixihuan(Integer id);
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    @Select({
        "select",
        "id, user_id, img_url, name, descn, status, create_time, update_time, view_count, ",
        "order_id, order_detail_id, product_id, example_type, case_time, case_hotel, ",
        "case_comment, case_detail, case_type, case_environment ",
        "from by_user_example",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    ByUserExample selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    int updateByExampleSelective(@Param("record") ByUserExample record, @Param("example") ByUserExampleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    int updateByExample(@Param("record") ByUserExample record, @Param("example") ByUserExampleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    int updateByPrimaryKeySelective(ByUserExample record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_user_example
     *
     * @mbggenerated Tue May 02 10:36:17 CST 2017
     */
    @Update({
        "update by_user_example",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "img_url = #{imgUrl,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "descn = #{descn,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler},",
          "view_count = #{viewCount,jdbcType=INTEGER},",
          "order_id = #{orderId,jdbcType=INTEGER},",
          "order_detail_id = #{orderDetailId,jdbcType=INTEGER},",
          "product_id = #{productId,jdbcType=INTEGER},",
          "example_type = #{exampleType,jdbcType=INTEGER},",
          "case_time = #{caseTime,jdbcType=VARCHAR},",
          "case_hotel = #{caseHotel,jdbcType=VARCHAR},",
          "case_comment = #{caseComment,jdbcType=VARCHAR},",
          "case_detail = #{caseDetail,jdbcType=VARCHAR},",
          "case_type = #{caseType,jdbcType=VARCHAR},",
          "case_environment = #{caseEnvironment,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ByUserExample record);
}